﻿var zTreeObj, rMenu;
var list = [];
var draw = 0;
var draw1 = 0;
var serviceId = "";
var folderId = "";
var table1, table2;
var ServiceTypelist = GetDataServiceTypeList();
var ServiceTypeId = "";
$(function () {
    var cookieFolderId = getCookie("DataServiceManagement_folderId");
    var cookieServiceId = getCookie("DataServiceManagement_serviceId");
    var cookieServiceTypeId = getCookie("DataServiceManagement_ServiceTypeId");
    if (cookieFolderId != undefined && cookieFolderId != "") {
        UpdateDataService(cookieFolderId);
        if (cookieServiceId != undefined && cookieServiceId != "" && cookieServiceTypeId != undefined && cookieServiceTypeId != "") {
            UpdateDataSource(cookieServiceId, cookieServiceTypeId);
        }
    }
    // zTree 的参数配置，深入使用请参考 API 文档（setting 配置详解）\
    var setting = {
        view: {
            dblClickExpand: false,
            selectedMulti: false
        },
        data: {
            simpleData: {
                enable: true,
                idKey: "Id",
                pIdKey: "parentId",
                rootPId: 0
            }
        },
        key: {
            checked: "Checked"
        },
        check: {
            enable: true
        },
        callback: {
            onRightClick: OnRightClick,
            onClick: zTreeOnClick,
            beforeRightClick: zTreeBeforeRightClick
        }
    };

    //获取表格所需的数据并填充到list数组 最后初始化表格
    function getData() {
        $.ajax({
            url: apiUrl,
            type: "Get",
            dataType: "json",
            async: false,
            data: { "sys:sno": "ETL", "sys:act": "GetDataServiceFolderTree" },
            success: function (data) {
                if (data.IsSccuess) {
                    if (data.Data.Items != null && data.Data.Items.length != 0) {
                        list = new Array();
                        combinedData(data.Data.Items, 0, "00000000-0000-0000-0000-000000000000");
                        list.push({ "Caption": "", name: "根节点", "Checked": true, "Code": "", "Id": "00000000-0000-0000-0000-000000000000", "parentId": "", "open": true });
                        zTreeObj = $.fn.zTree.init($("#DataServiceFolderTree"), setting, list);
                        console.log(JSON.stringify(list));
                    }
                } else {
                    if (IsLogined(data.ErrorCode)) {
                        alert("错误代码：" + data.ErrorCode + "，错误信息：" + data.Message);
                    }
                }
            },
            error: function () {
                alert("系统异常，请稍后重试");
            }
        });
    }

    function zTreeBeforeRightClick(treeId, treeNode) {

        return (treeNode.idKey != 0);
    };

    function OnRightClick(event, treeId, treeNode) {
        if (treeNode) {
            if (treeNode.isParent) {
                zTreeObj.selectNode(treeNode);
                if (treeNode.Id == "00000000-0000-0000-0000-000000000000") {
                    showRMenu("root", event.clientX, event.clientY);
                } else {
                    showRMenu("parent", event.clientX, event.clientY);
                }
            } else {
                zTreeObj.selectNode(treeNode);
                showRMenu("node", event.clientX, event.clientY);
            }
        }
    }

    //单击事件
    function zTreeOnClick(event, treeId, treeNode) {
        if (treeNode.Id == "00000000-0000-0000-0000-000000000000") {
            console.log("顶级根无关联人员");
        } else {
            clearDataSource();
            UpdateDataService(treeNode.Id);

        }
    };

    //新增数据服务目录表单
    $("#AddModelForm").validate({
        submitHandler: function () {
            $.ajax({
                url: apiUrl,
                data:
                    $("#AddModelForm").serialize(),
                type:
                    "Post",
                dataType:
                    "json",
                success:
                    function (data) {
                        if (data.IsSccuess)
                            ShowGritter("新增成功", 2);
                        else if (IsLogined(data.ErrorCode))
                            alert(data.Message);
                    },
                beforeSend: function () {
                    ShowGritter("提交中");
                },
                error: function () {
                    alert("系统异常，请稍后重试");
                }
            });
        }
    });
    //提交更新数据服务目录表单
    $("#UpdateModelForm").validate({
        submitHandler: function () {
            $.ajax({
                url: apiUrl,
                type: "Post",
                dataType: "json",
                async: false,
                data: $("#UpdateModelForm").serialize(),
                success: function (data) {
                    if (data.IsSccuess) {
                        ShowGritter("编辑成功", 2);
                    } else {
                        if (IsLogined(data.ErrorCode)) {
                            alert("错误代码：" + data.ErrorCode + "，错误信息：" + data.Message);
                        }
                    }
                },
                beforeSend: function () {
                    ShowGritter("提交中");
                },
                error: function () {
                    alert("系统异常，请稍后重试");
                }
            });
        }
    });
    rMenu = $("#rMenu");
    getData();
    updateDataServiceFolderTree();
});
//递归查找数据并组合成列表
var combinedData = function (source, i, partentId) {
    for (var j = 0; j < source.length; j++) {

        list.push({ "Caption": source[j].Caption, name: (source[j].Caption + "(" + source[j].Code + ")"), "Code": source[j].Code, "Id": source[j].Id, "parentId": partentId, "open": true });
        if (source[j].Items != null && source[j].Items.length > 0) {
            combinedData(source[j].Items, i + 1, source[j].Id);
        }
    }
}
//更新服务目录select下拉框
var updateDataServiceFolderTree = function () {
    $("#update-FolderId").html("  <option value='00000000-0000-0000-0000-000000000000'>根目录<\/option>");
    $("#add-FolderId").html("  <option value='00000000-0000-0000-0000-000000000000'>根目录<\/option>");
    var list = GetDataServiceFolderTree();
    $("#add-FolderId").append(list);
    $("#update-FolderId").append(list);
}
function showRMenu(type, x, y) {
    $("#rMenu ul").show();
    if (type == "root") {
        $("#m_del").hide();
        $("#m_edit").hide();
        // $("#m_look").hide();
    } else if (type == "parent") {
        $("#m_del").hide();
    } else {
        $("#m_del").show();
        $("#m_edit").show();
        // $("#m_look").show();

    }
    rMenu.css({ "top": (parseInt(y)) + "px", "left": (parseInt(x)) + "px", "visibility": "visible" });
    $("body").bind("mousedown", onBodyMouseDown);
}

function hideRMenu() {
    if (rMenu) rMenu.css({ "visibility": "hidden" });
    $("body").unbind("mousedown", onBodyMouseDown);
}

/*添加body的左击事件*/
function onBodyMouseDown(event) {
    if (!(event.target.id == "rMenu" || $(event.target).parents("#rMenu").length > 0)) {
        rMenu.css({ "visibility": "hidden" });
    }
}
/*新增故障信息*/
function addTreeNode() {
    hideRMenu();
    var treeNode = zTreeObj.getSelectedNodes()[0];
    //treeNode.idKey
    document.getElementById("UpdateModelForm").reset();
    var id = treeNode.Id;
    $("#add-FolderId").val(id);
    $('#AddModel').modal({
        show: true
    });

}
/*删除故障信息*/
function removeTreeNode() {
    hideRMenu();
    var treeNode = zTreeObj.getSelectedNodes()[0];
    var id = treeNode.Id;
    if (confirm("是否删除？")) {
        $.ajax({
            url: apiUrl,
            type: "Post",
            dataType: "json",
            async: false,
            data: { "sys:sno": "ETL", "sys:act": "DeleteDataServiceFolder", Id: id },
            success: function (data) {
                if (data.IsSccuess) {
                    ShowGritter("删除成功", 2);
                } else {
                    if (IsLogined(data.ErrorCode)) {
                        alert("错误代码：" + data.ErrorCode + "，错误信息：" + data.Message);
                    }
                }
            },
            beforeSend: function () {
                ShowGritter("提交中");
            },
            error: function () {
                alert("系统异常，请稍后重试");
            }
        });
    }
}
/*编辑故障信息*/
function EditTreeNode() {
    hideRMenu();
    var treeNode = zTreeObj.getSelectedNodes()[0];
    var id = treeNode.Id;
    for (var i = 0; i < list.length; i++) {
        if (id == list[i].Id) {
            $("#update-FolderId").val(list[i].parentId);
            if (list[i].parentId == "") {
                $("#update-FolderId").val("00000000-0000-0000-0000-000000000000");
            }
            $("#update-Folder-Code").val(list[i].Code);
            $("#update-Folder-Caption").val(list[i].Caption);
        }
    }
    $("#update-Folder-Id").val(id);
    $('#UpdateModel').modal({
        show: true
    });
}


var UpdateDataService = function (id) {
    console.log("正在努力的加在数据服务列表！");
    folderId = id;
    setCookie("DataServiceManagement_folderId", folderId, 1);
    setCookie("DataServiceManagement_ServiceTypeId", "", -1);
    setCookie("DataServiceManagement_serviceId", "", -1);
    if (draw1 != 0) {
        table1.fnDraw();
    } else {
        CreateTableForDaraService();
    }
}
var clearDataSource = function () {
    if (draw != 0) {
        //table2.fnClearTable();
        $("#wid-id-1").hide();
    }
}
var UpdateDataSource = function (id, typeId) {
    console.log("正在努力的加在数据源列表！");
    $("#wid-id-1").show();
    ServiceTypeId = typeId;
    serviceId = id;
    setCookie("DataServiceManagement_ServiceTypeId", typeId, 1);
    setCookie("DataServiceManagement_serviceId", serviceId, 1);

    if (draw != 0) {
        table2.fnDraw();
    } else {
        CreateTableForDaraSource();
    }
}
var CreateTableForDaraService = function () {
    //初始化表格
    try {
        table1 = $('#datalist-table-dataservice').dataTable({
            "autoWidth": true,
            "oLanguage": dataTableConfig,
            "bLengthChange": false,
            ordering: false,

            bProcessing: true,
            serverSide: true,
            searching: false,
            aLengthMenu: [25],
            "ajax": {
                "url": apiUrl,
                "dataSrc": function (json) {
                    if (json.IsSccuess) {
                        var newjson = new Array();
                        for (var i = 0; i < json.Data.Items.length; i++) {
                            var obj = json.Data.Items[i];
                            //var servicestr = "<a href=\"";
                            var servicetypenamestr = GetServiceTypeName(obj.TypeId);
                            var editstr = "<a href=\"DataServiceUpdateInfo.html?Id=" + obj.Id + "&serviceType=" + escape(servicetypenamestr);
                            editstr += "\" data-tipsy='tipsy' data-title='编辑'><i class=\"fa fa-pencil-square-o\"></i></a>";
                            editstr += "<a href=\"javascript:void(0);\" onclick=\"DeleteService(this)\" data-Id=\"" + json.Data.Items[i].Id;
                            editstr += "\" data-tipsy='tipsy' data-title='删除'><i class=\"fa  fa-times-circle\" ></i></a>";
                            editstr += ("<a href=\"javascript:void(0);\" onclick=\"EnableOrDisableService(this)\" data-Id=\"" + json.Data.Items[i].Id + "\" data='" + obj.IsEnabled + "'data-tipsy='tipsy' data-title='" + (obj.IsEnabled ? "禁用" : "启用") + "'><i class=\"fa   " + (obj.IsEnabled ? "fa-circle" : "fa-dot-circle-o ") + "\"></i></a>");
                            var updatesource = "<a href='javascript:void(0);' onclick=\"UpdateDataSource('";
                            updatesource += (obj.Id + "','" + GetServiceTypeName(obj.TypeId) + "')\" >" + obj.UnmappedCount + "</a>");
                            var servicestr = ("<a href='" + GetServiceDetailsUrl(obj.TypeId) + "?Id=" + obj.Id + "' >" + obj.Name + "</a>");
                            newjson.push({ "service": servicestr, "RawData": obj, "type": servicetypenamestr, "address": "<a href='javascript:void(0);' data-tipsy='tipsy' data-title='" + obj.Address + "'>" + (obj.Address.length > 40 ? obj.Address.substring(0, 40) : obj.Address) + "</a>", "state": obj.IsEnabled ? "启用" : "禁用", "datasource": updatesource, "isconfig": obj.MappedCount, "option": editstr });
                        }
                        return newjson;
                    } else {
                        if (IsLogined(json.ErrorCode)) {
                            alert("错误代码：" + json.ErrorCode + "，错误信息：" + json.Message);
                        }
                    }
                    return [];
                },
                "data": function (d) {
                    draw1 = d.draw;
                    return $.extend({}, { "sys:sno": "ETL" }, { "sys:act": "GetDataServiceList" }, { "draw": draw1 }, { "length": d.length }, { "FolderId": folderId }, { "Page": parseInt(d.start / d.length) });
                }
            },
            columns: [
                { data: 'service', "sWidth": "15%" },
                { data: 'type', "sWidth": "10%" },
                { data: 'address' },
                { data: 'state', "sWidth": "8%" },
                { data: 'datasource', "sWidth": "8%" },
                { data: 'isconfig', "sWidth": "8%" },
                { data: 'option', "sWidth": "10%" }
            ],
            fnDrawCallback: function () {
                ShowToolTip();
                table1.$('tr').click(function () {
                    $(".onclcik").removeClass("onclcik");
                    $(this).addClass("onclcik");
                    var data = table1.fnGetData(this);
                    UpdateDataSource(data.RawData.Id, data.RawData.TypeId);

                });
            }
        });

    } catch (e) {
        console.log(e);
    }

}
var CreateTableForDaraSource = function () {
    //初始化表格
    table2 = $('#datalist-table-datasource').dataTable({
        "autoWidth": true,
        "oLanguage": dataTableConfig,
        "bLengthChange": false,
        ordering: false,

        bStateSave: true,
        serverSide: true,
        searching: false,
        aLengthMenu: [25],
        bProcessing: true,
        "ajax": {
            "url": apiUrl,
            "dataSrc": function (json) {
                if (json.IsSccuess) {
                    var newjson = new Array();
                    for (var i = 0; i < json.Data.Items.length; i++) {
                        var datasourcestr = GetSourceDetailsUrl(ServiceTypeId);
                        if (datasourcestr != "") {
                            datasourcestr = "<a href='" + GetSourceDetailsUrl(ServiceTypeId) + "?Id=" + serviceId + "&datasourceId=" + json.Data.Items[i].Id + "'>" + json.Data.Items[i].Name + "</a>";
                        } else {
                            datasourcestr = json.Data.Items[i].Name;
                        }
                        var datatablestr = "";
                        if (json.Data.Items[i].MappingTable == "") {
                            datatablestr = "<a href=\"ChoseDataSourceMappingType.html?Id=" + serviceId + "&datasourceId=" + json.Data.Items[i].Id + "&sysno=" + GetSys_Sno(ServiceTypeId) + "\">" + "none</a>";
                        } else {
                            datatablestr = "<a href=\"DataSourceMappingDataBaseForMappingFilds.html?Id=" + serviceId + "&datasourceId=" + json.Data.Items[i].Id + "&tableId=" + json.Data.Items[i].MappingTableId + "&sysno=" + GetSys_Sno(ServiceTypeId) + "\">" + json.Data.Items[i].MappingTable + "</a>";
                        }
                        var editstr = "";
                        if (ServiceTypeId == "c7e6e4ca-fc41-41e7-a693-201607a27b39") {
                            editstr = "<a href=\"" + GetSourceDetailsUrl(ServiceTypeId) + "?Id=" + serviceId + "&datasourceId=" + json.Data.Items[i].Id;
                            editstr += "\" data-tipsy='tipsy' data-title='编辑'><i class=\"fa fa-pencil-square-o\"></i></a>";
                        } else {
                            editstr = "<a href=\"" + GetSourceDetailsUrl(ServiceTypeId) + "?Id=" + serviceId + "&datasourceId=" + json.Data.Items[i].Id;
                            editstr += "\" data-tipsy='tipsy' data-title='编辑'><i class=\"fa fa-pencil-square-o\"></i></a>";
                            editstr += "<a href=\"javascript:void(0);\" class=\"data-delete\" data-Id=\"" + json.Data.Items[i].Id;
                            editstr += "\" data-tipsy='tipsy' data-title='删除'><i class=\"fa  fa-times-circle\"></i></a>";
                        }
                        newjson.push({ "dataSource": datasourcestr, "dataTable": datatablestr, "type": GetSourceTypeName(ServiceTypeId, json.Data.Items[i].Type), "option": editstr });
                    }
                    return newjson;
                } else {
                    if (IsLogined(json.ErrorCode)) {
                        alert("错误代码：" + json.ErrorCode + "，错误信息：" + json.Message);
                    }
                }
                return [];
            },
            "data": function (d) {
                draw = d.draw;
                return $.extend({}, { "sys:sno": "ETL" }, { "sys:act": "GetDataSourceList" }, { "draw": d.draw }, { "length": d.length }, { "DataServiceId": serviceId }, { "Page": parseInt(d.start / d.length) });
            }
        },
        columns: [
            { data: 'dataSource' },
              { data: 'type' },
            { data: 'dataTable' },
        { data: 'option' }

        ],
        fnDrawCallback: function () {
            band();
            ShowToolTip();
        }
    });
}
var band = function () {
    $(".data-delete").click(function () {
        if (confirm("是否删除？")) {
            var $this = $(this);
            var id = $(this).attr("data-Id");

            $.ajax({
                url: apiUrl,
                type: "Post",
                dataType: "json",
                async: false,
                data: { "sys:sno": "ETL", "sys:act": "DeleteDataSource", "DataSourceId": id, "DataServiceId": serviceId },
                success: function (data) {
                    if (data.IsSccuess) {
                        if (DeleteDataThenReload) {
                            ShowGritter("删除成功", 2);
                        } else {
                            ShowGritter("删除成功");
                            $this.parent().parent().remove();
                        }
                    } else {
                        if (IsLogined(data.ErrorCode)) {
                            alert("失败（" + "错误代码：" + data.ErrorCode + "，错误信息：" + data.Message + ")");
                        }
                    }
                },
                beforeSend: function () {
                    ShowGritter("提交中");
                },
                error: function () {
                    alert("系统异常，请稍后重试");
                }
            });
        }
    });
}
var GetServiceTypeName = function (typeId) {
    if (ServiceTypelist != null && ServiceTypelist.length != 0) {
        for (var i = 0; i < ServiceTypelist.length; i++) {
            if (typeId == ServiceTypelist[i].Id) {
                return ServiceTypelist[i].Caption;
            }
        }
    }
    return "暂无";
}
//获取数据源
var GetSourceTypeName = function (serviceTypeId, typeId) {
    if (serviceTypeId == "8d09625b-f618-45c3-81f1-65ad3df3373a") {
        return "Method";
    } else if (serviceTypeId == "872bae09-6b32-4dba-a1c9-b24af3d79757") {
        return "Sheet";
    } else if (serviceTypeId == "fbc88932-8500-4d98-b795-ff84aeb002c3") {
        switch (typeId) {
            case 1:
                return "脚本";
            case 2:
                return "存储过程";
        }
    } else if (serviceTypeId == "1ad086ab-2428-48a3-a845-1b11ede2c92a") {
        switch (typeId) {
            case 1:
                return "脚本";
            case 2:
                return "存储过程";
        }
    } else if (serviceTypeId == "9e009b1a-98b5-44c6-8d85-525d9a3952e9") {
        switch (typeId) {
            case 1:
                return "脚本";
            case 2:
                return "存储过程";
        }
    } else if (serviceTypeId == "09f75019-cbea-401a-80a4-47502c057302") {
        return "RawData";
    } else if (serviceTypeId == "d75c0354-4f07-4c2d-80b5-055b3105401e") {
        return "DataService";
    } else if (serviceTypeId == "c7e6e4ca-fc41-41e7-a693-201607a27b39") {
        return "Extension";
    } else {
        return "暂无";
    }

}
//获取数据源详情地址
var GetServiceDetailsUrl = function (typeId) {
    if (typeId == "8d09625b-f618-45c3-81f1-65ad3df3373a") {
        return "DataSourceDetails-WebService.html";
    } else if (typeId == "872bae09-6b32-4dba-a1c9-b24af3d79757") {
        return "DataSourceDetails-Excel.html";
    } else if (typeId == "fbc88932-8500-4d98-b795-ff84aeb002c3") {
        return "DataSourceDetails-DatabaseSQL.html";
    } else if (typeId == "09f75019-cbea-401a-80a4-47502c057302") {
        return "DataSourceDetails-RawData.html";
    } else if (typeId == "d75c0354-4f07-4c2d-80b5-055b3105401e") {
        return "DataSourceDetails-DataService.html";
    } else if (typeId == "c7e6e4ca-fc41-41e7-a693-201607a27b39") {
        return "DataSourceDetails-Extension.html";
    } else if (typeId == "1ad086ab-2428-48a3-a845-1b11ede2c92a") {
        return "DataSourceDetails-MySql.html";
    } else if (typeId == "9e009b1a-98b5-44c6-8d85-525d9a3952e9") {
        return "DataSourceDetails-Oracle.html";
    } else {
        return "";
    }
}
//获取数据源详情地址
var GetSourceDetailsUrl = function (typeId) {
    if (typeId == "8d09625b-f618-45c3-81f1-65ad3df3373a") {
        //web service
        return "UpdateDtSrcWS.html";
    } else if (typeId == "872bae09-6b32-4dba-a1c9-b24af3d79757") {
        return "CreateDataSource-Excel.html";
    } else if (typeId == "fbc88932-8500-4d98-b795-ff84aeb002c3") {
        return "UpdateDtSerSQL.html";
    } else if (typeId == "09f75019-cbea-401a-80a4-47502c057302") {
        return "UpdateDataSource-RawData.html";
    } else if (typeId == "d75c0354-4f07-4c2d-80b5-055b3105401e") {
        return "UpdateDtSerStdDS.html";
    } else if (typeId == "c7e6e4ca-fc41-41e7-a693-201607a27b39") {
        //ExtDS
        return "UpdateDtSrc.html";
    } else if (typeId == "1ad086ab-2428-48a3-a845-1b11ede2c92a") {
        return "CreateDataSource-MySql.html";
    } else if (typeId == "9e009b1a-98b5-44c6-8d85-525d9a3952e9") {
        return "CreateDataSource-Oracle.html";
    } else {
        return "";
    }

}
//获取服务获取api的Sys_Sno
var GetSys_Sno = function (typeId) {
    if (typeId == "8d09625b-f618-45c3-81f1-65ad3df3373a") {
        return "WS";
    } else if (typeId == "872bae09-6b32-4dba-a1c9-b24af3d79757") {
        return "Excel";
    } else if (typeId == "fbc88932-8500-4d98-b795-ff84aeb002c3") {
        return "SQL";
    } else if (typeId == "09f75019-cbea-401a-80a4-47502c057302") {
        return "RDS";
    } else if (typeId == "d75c0354-4f07-4c2d-80b5-055b3105401e") {
        return "DS";
    } else if (typeId == "c7e6e4ca-fc41-41e7-a693-201607a27b39") {
        return "ExtDS";
    } else if (typeId == "1ad086ab-2428-48a3-a845-1b11ede2c92a") {
        return "MySql";
    } else if (typeId == "9e009b1a-98b5-44c6-8d85-525d9a3952e9") {
        return "Oracle";
    } else {
        return "";
    }

}
var EnableOrDisableService = function (obj) {
    var $this = $(obj);
    var state = $this.attr("data");
    var dataServiceId = $this.attr("data-Id");
    var str = "";
    var act = "";
    var successstr = "";
    if (state == "true") {
        str = "禁用";
        act = "DisableDataService";
    } else {
        str = "启用";
        act = "EnableDataService";
    }
    if (confirm("确定" + str + "该服务？")) {
        $.ajax({
            url: apiUrl,
            data: {
                "sys:sno": "ETL",
                "sys:act": act,
                "DataServiceId": dataServiceId
            },
            type: "Post",
            dataType: "json",
            success: function (data) {
                if (data.IsSccuess) {
                    ShowGritter(str + "成功");
                    table1.fnDraw();
                    clearDataSource();
                } else {
                    if (IsLogined(data.ErrorCode)) {
                        alert("错误代码：" + data.ErrorCode + "，错误信息：" + data.Message);
                    }
                }
            },
            beforeSend: function () {
                ShowGritter("提交中");
            },
            error: function () {
                alert("系统异常，请稍后重试");
            }
        });
    }
}
var DeleteService = function (obj) {
    var $this = $(obj);
    var dataServiceId = $this.attr("data-Id");

    if (confirm("确定删除该项？")) {
        $.ajax({
            url: apiUrl,
            data: {
                "sys:sno": "ETL",
                "sys:act": "DeleteDataService",
                "DataServiceId": dataServiceId
            },
            type: "Post",
            dataType: "json",
            success: function (data) {
                if (data.IsSccuess) {
                    if (DeleteDataThenReload) {
                        ShowGritter("删除成功", 2);
                    } else {
                        ShowGritter("删除成功");
                        $this.parent().parent().remove();
                    }
                    clearDataSource();
                } else {
                    if (IsLogined(data.ErrorCode)) {
                        alert("错误代码：" + data.ErrorCode + "，错误信息：" + data.Message);
                    }
                }
            },
            beforeSend: function () {
                ShowGritter("提交中");
            },
            error: function () {
                alert("系统异常，请稍后重试");
            }
        });
    }
}